!! to-sph 主要是 ti-sph 的前处理程序，可用于初始化粒子

!> author: 左志华
!> date: 2022-05-02
!>
!> sph / ti-sph pre-post-processing program <br>
!> sph 前后处理程序 -- to-sph
program main

    use seakeeping_time, only: timer
    use seakeeping_filesystem, only: is_exist, operator(.join.), mkdir
    use argparse, only: argparser
    use sph_region_type, only: region_t
    use sph, only: cmd_pre, cmd_post
    use sph_terminal, only: red, set_terminal
    use sph_command_line, only: get_cmd_settings, cmd_settings_t, pre_settings_t, post_settings_t

    type(region_t) :: region
    class(cmd_settings_t), allocatable :: cmd_settings  !! Command line settings <br>
                                                        !! 命令行设置
    character(:), allocatable :: manifest, error
    type(timer) :: time  !! 计时器记录
    type(argparser) :: cli  !! 命令行解析器

    ! ----------------------- 启动 To-SPH 程序 ----------------------- !
    call time%tic()
    call set_terminal(use_color=.true.)
    call get_cmd_settings(cli, cmd_settings)

    ! ------------------------- 运行核心程序 ------------------------- !
    manifest = cmd_settings%working_dir.join."sph-config.nml"
    ! call get_project_configuration(manifest, project)

    print '(a)', '*** Particle Model Pre- and Post-Processors, To-SPH v0.3.5'

    select type (cmd_settings)
    type is (pre_settings_t)
        call cmd_pre(cmd_settings, region)
    type is (post_settings_t)
        call cmd_post(cmd_settings, region)
    end select

    ! --------------------------- 运行结束 -------------------------- !
    print '(/a)', '*** All done! Thanks for using To-SPH!'
    call time%toc(time%nowtime())
end program main
